package com.remenote.remenoteback.controller;

import com.remenote.remenoteback.entity.req.DeckRequest;
import com.remenote.remenoteback.entity.resp.ServerResponse;
import com.remenote.remenoteback.entity.vo.DeckVo;
import com.remenote.remenoteback.service.CardService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/card")
public class CardController {

    @Autowired
    private CardService cardService;

    @PostMapping("/listDecks")
    ServerResponse<List<DeckVo>> listDecks() {
        return cardService.listDecks();
    }

    @PostMapping("/getDeck")
    ServerResponse<DeckVo> getDeck(@RequestBody DeckRequest deckRequest) {
        return cardService.getDeck(deckRequest.getDeckId());
    }

    @PostMapping("/search")
    ServerResponse<List<DeckVo>> search(@RequestBody DeckRequest deckRequest) {
        return cardService.search(deckRequest.getDeckName());
    }
    @PostMapping("/saveDeck")
    ServerResponse saveDeck(@RequestBody DeckRequest deckRequest) {
        return cardService.saveDeck(deckRequest);
    }

    @PostMapping("/createDeck")
    ServerResponse createDeck(@RequestBody DeckRequest deckRequest) {
        return cardService.createDeck(deckRequest);
    }

    @PostMapping("/deleteDeck")
    ServerResponse deleteDeck(@RequestBody DeckRequest deckRequest) {
        return cardService.deleteDeck(deckRequest.getDeckId());
    }
}